//: Playground - noun: a place where people can play

import Foundation

var str = "Hello, playground"

let str2 = "fuckyou中\u{1F496}"


str += " hahahehe"

var emptyString = ""

var anotherEmptyString = String()

emptyString.isEmpty
anotherEmptyString.isEmpty


//for c in str2
//{
//    
//    print(c)
//}

var ch:Character = "!"
str.append(ch)

var str3 = "!!!!!"

str += str3

str2.characters.count


var str4:NSString = str2
str4.length


var str5 = "hello"
str5 += " imooc!"



//let imInt:Int = 2
//print("Int"\(imInt)")

let str_a = "abc"
let str_b = "abc"

str_a == str_b


str_a.hasPrefix("ab")
str_a.hasSuffix("bc")

let arr = ["abb","abc","abcd"]
var count = 0;
for name in arr{
    if name.hasPrefix("ab") {
        count++
    }
}

count


str_a.capitalizedString
str_a.uppercaseString
str_a.lowercaseString

var str_c = "     !hi!!!!!   "
str_c.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
str_c.stringByTrimmingCharactersInSet(NSCharacterSet(charactersInString: " !"))

var str_d = "o o o fuck me"
str_d.componentsSeparatedByString(" ")


//var str_e:String = "-"
//str_e.join(["1","2","3"])

str_d.rangeOfString("o")
str_d.rangeOfString("o",options: NSStringCompareOptions.BackwardsSearch)

str_d.startIndex
str_d.endIndex

let strRange = Range<String.Index>(start: str_d.startIndex, end: str_d.endIndex)

let startIndex : String.Index = str_d.startIndex
let endIndex : String.Index = str_d.startIndex.advancedBy(11)
let searchRange = Range<String.Index>(start: startIndex, end: endIndex)

str_d.rangeOfString("fuck",options: NSStringCompareOptions.CaseInsensitiveSearch,range:searchRange)

var toIndex = str_d.startIndex.advancedBy(4)
str_d.substringToIndex(toIndex)

var FromIndex = str_d.startIndex.advancedBy(10)
str_d.substringFromIndex(FromIndex)

str_d.substringWithRange(Range<String.Index>(start: toIndex, end: FromIndex))


var insertIndex = str_d.startIndex.advancedBy(11)
str_d.insert("!", atIndex: insertIndex)

str_d.removeAtIndex(insertIndex)

str_d.replaceRange(Range<String.Index>(start: toIndex, end: FromIndex), with: "l")

